#ifndef TCP_MAINWINDOW_H
#define TCP_MAINWINDOW_H

#include <QMainWindow>
#include <QTcpSocket>
#include <QTcpServer>
#include <QVector>


namespace Ui {
class TCP_MainWindow;
}

struct TcpInfo
{
    int index;
    QTcpSocket *cliet_socket;
};

class TCP_MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit TCP_MainWindow(QWidget *parent = 0);
    ~TCP_MainWindow();

private slots:
    void new_client();
    void read_client_data();
    void client_dis();
    void cleanConnect(QTcpSocket *socket);
    void show_error(QAbstractSocket::SocketError);

    void on_pushButton_serv_send_clicked();

    void on_pushButton_bind_clicked();

    void on_pushButton_serv_clear_clicked();

    void on_pushButton_serv_disconn_clicked();

    void on_pushButton_connect_clicked();

    void on_pushButton_clie_send_clicked();

    void on_pushButton_clie_clear_clicked();

    void on_pushButton_clie_disconn_clicked();


private:
    Ui::TCP_MainWindow *ui;
    QTcpServer* server_socket;
    //QTcpSocket* cliet_socket;
    QTcpSocket* cliet;

    QVector<TcpInfo> vTcpInfo; //socket结构体


};

#endif // TCP_MAINWINDOW_H
